<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableRobotSite extends Migrator
{
    public function up()
    {
        if (!$this->hasTable('robot_site')) {
            $table = $this->table('robot_site', ['engine' => 'MyISAM'])
                ->setId('id')
                ->setPrimaryKey('id')
                ->setComment('机器人设置表');
            $table->addColumn('robot_wxid', 'string', ['limit' => 100, 'null' => false, 'comment' => '机器人id'])
                ->addColumn('title', 'string', ['limit' => 100, 'null' => false, 'default' => '', 'comment' => '命中标题'])
                ->addColumn('content', 'string', ['limit' => 500, 'null' => false, 'default' => '', 'comment' => '回复词'])
                ->addIndex(['robot_wxid','title'])
                ->create();
        }
    }

    public function down()
    {
        if ($this->hasTable('robot_site')) {
            $this->dropTable('robot_site');
        }
    }
}
